<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm"  :inline="true" label-width="98px" v-show="showSearch">
            <el-form-item label="交接工作名称" prop="name">
                <el-input v-model="queryParams.name" placeholder="请输入交接工作名称" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="移交时间" prop="yijaoDate">
                <el-date-picker v-model="queryParams.yijaoDate" type="date" value-format="yyyy-MM-dd" placeholder="选择移交时间">
                </el-date-picker>
            </el-form-item>
          <el-form-item label="流程状态" prop="state">
            <el-select v-model="queryParams.state" placeholder="请选择">
              <el-option v-for="item in dict.type.LCZT" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" v-hasPermi="['archive:yijiaoDan:selectHandOverReceive1']" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8" ref="refbut">
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange" border :height="tableHeight">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="序号" align="center" type="index" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="255">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="dark" content="下载移交接收登记表Excel" placement="top-start">
                        <el-button icon="el-icon-download" plain  circle  v-show="scope.row.state == 2"
                                   v-hasPermi="['archive:yijiaoDan:exportXlsx1']" @click="onClick(0, scope.row)" size="small"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="下载移交接收登记表" placement="bottom-start">
                        <el-button type="warning" icon="el-icon-download" plain  circle  v-show="scope.row.state == 2"
                                   v-hasPermi="['archive:yijiaoDan:exportWord1']" @click="onClick(1, scope.row)" size="small"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="打印移交接收登记表" placement="top-start">
                        <el-button type="success" icon="el-icon-printer"  plain circle  v-show="scope.row.state == 2"
                                   v-hasPermi="['archive:yijiaoDan:selectHandOverReceiveById1']" @click="onClick(2, scope.row)" size="small"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="下载移交包" placement="bottom-start">
                        <el-button type="info" icon="el-icon-download"  plain circle  v-show="scope.row.state == 2"
                                   v-hasPermi="['archive:yijiaoDan:yijiaopack']" @click="onClick(3, scope.row)" size="small"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="标记接收" placement="top-start">
                        <el-button type="danger" icon="el-icon-takeaway-box"  plain circle  v-show="scope.row.state == 2"
                                   v-hasPermi="['archive:yijiaoDan:jsState1']" @click="onClick(4, scope.row)" size="small"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="打印四性检测报告" placement="bottom-start">
                        <el-button type="primary" icon="el-icon-printer"  plain circle  v-show="scope.row.state == 2"
                            @click="onClick(5, scope.row)" size="small"></el-button>
                    </el-tooltip>
                </template>
            </el-table-column>
            <el-table-column label="交接工作名称" align="center" prop="name" />
            <el-table-column label="移交单位" align="center" prop="yjUnit" />
            <el-table-column label="移交填表人" align="center" prop="createBy" />
            <el-table-column label="移交审核人" align="center" prop="auditorBy" />
            <el-table-column label="移交日期" align="center" prop="createTime" />
            <el-table-column label="移交状态" align="center" prop="yjState">
                <template slot-scope="scope">
                    {{ scope.row.yjState == 1 ? "已移交" : "未移交" }}
                </template>
            </el-table-column>
          <el-table-column label="流程状态" align="center" prop="state">
            <template slot-scope="scope">
                    <span v-for="(i, idx) in dict.type.LCZT" :key="idx">
                        {{ scope.row.state == i.value ? i.label : '' }}
                    </span>

            </template>
          </el-table-column>
            <el-table-column label="接收状态" align="center" prop="jsState">
                <template slot-scope="scope">
                    {{ scope.row.jsState == 1 ? "已接收" : "未接收" }}
                </template>
            </el-table-column>

        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
        <!-- 打印移交接收登记表弹出窗 -->
        <printOrder v-if="printRow" :open="printOrderOpen" @closeDelDialog="closeDelDialog" :printRow="printRow" source="offline" :printShow="true" :printTitle="printTitle">
        </printOrder>
        <!-- 打印四性检测报告弹出窗 -->
        <printSxjc v-if="printSXJCOpen" :open="printSXJCOpen" @closeDelDialog="closeDelDialog" :sxjcId="sxjcId">
        </printSxjc>
    </div>
</template>

<script>
import { selectHandOverReceive1, jsState1, listinfo} from "@/api/archive/archiveTransfer/archiveTransfer.js";
import estimateTableHeight from '@/mixins/estimateTableHeight';
import printOrder from "@/views/archive/archiveTransfer/offline/printOrder.vue"
import printSxjc from "@/views/archive/archiveTransfer/offline/printsxjc.vue"
export default {
    archive_Dicts: ['LCZT'],
    mixins: [estimateTableHeight], // 混入方法
    components: {
        printOrder,
        printSxjc
    },
    data() {
        return {
            showSearch: true,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 总条数
            total: 0,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                type: "outLine",
                name: undefined,
                yijaoDate: undefined
            },
            list: [],
            stateList: [],
            printOrderOpen: false,//打印移交接收登记表弹出窗
            printSXJCOpen: false, //打印四性检测弹出层
            printRow: "", //打印获取的数据
            sxjcId:"", //获取列表的检测ID
            printTitle:"打印移交接收登记表"
        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询表单管理列表 */
        getList() {
            this.loading = true;
            selectHandOverReceive1(this.queryParams).then(response => {
                console.log(response, "skldfjlksdfjklsdj")
                this.list = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                formId: null,
                formName: null,
                formCode: null,
                isEnable: null
            };
            this.resetForm("form");
        },

        handleClose(value) {
            this.openSelect = value
        },
        handleCloseRule(value) {
            this.openSelectRule = value
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.formId)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },

        onClick(val, row) {

            //下载移交接收登记表Excel  val==0
            if (val == 0) {
                this.download('archive/yijiaoDan/exportXlsx1', {
                    id: row.id
                }, `exportXlsx_${new Date().getTime()}.xlsx`)
            }
            //下载移交接收登记表
            if (val == 1) {
                this.download('archive/yijiaoDan/exportWord1', {
                    id: row.id
                }, `exportWord_${new Date().getTime()}.doc`)
            }
            // 打印移交接收登记表
            if (val == 2) {
                console.log(row,"sdklfjkl")
                this.printRow = row;
                this.printOrderOpen = true;
            }

            //下载移交包
            if (val == 3) {
                this.download('archive/yijiaoDan/yijiaopack', {
                    id: row.id
                }, `pack_${new Date().getTime()}.zip`)
                this.getList();

            }

            //标记接收
            if (val == 4) {
                jsState1({
                    id: row.id
                }).then(res => {
                    this.getList();
                })
            }
            //四性检测报告打印
            if (val == 5) {
               this.printSXJCOpen=true;
               console.log(row,"+++++")
               this.sxjcId=row.siXingId
            }
        },
        //关闭弹窗
        closeDelDialog() {
            this.printOrderOpen = false;
            this.printSXJCOpen=false;
        },
        /** 导出按钮操作 */
        // handleExport() {
        //     this.download('archive/formManage/export', {
        //         ...this.queryParams
        //     }, `formManage_${new Date().getTime()}.xlsx`)
        // }
    }
};
</script>
